import axios from 'axios';

let baseUrl = 'https://app.zhengyunkeji.net/apptest-api';
const instance = axios.create({
	baseURL:baseUrl,
	timeout: 3000
});


instance.interceptors.request.use(
  config => {
	 const token = uni.getStorageSync('X-Token');
    if (token) { //判断token是否存在
      config.headers['x-token'] = token;  //将token设置成请求头
	  config.headers['X-Terminal'] = 'ROLE_KH';
	  config.headers['X-Terminal-Ver'] = uni.getSystemInfoSync().appVersion;
    }
    return config;
  },
  err => {
    return Promise.reject(err);
  }
);

export default instance;